package lab01;

public class Test05 {
    public static void main(String[] args) {
        forAdd();
        whileAdd();
        doAdd();
    }
    public static void forAdd() {
        int sum=0;
        for (int i=1;i<=50;i++){

            sum=sum+i;
        }
        System.out.println("(for)sum="+sum);
    }
    public static void whileAdd() {
        int j = 0;
        int sum1 = 0;
        while (j <= 50) {

            sum1 = sum1 + j;
            j++;
        }
        System.out.println("(while)sum1=" + sum1);
    }
    public static void doAdd(){
        int n=0,sum2=0;
        do {
            sum2=sum2+n;
            n++;
        }while(n<=50);

        System.out.println("(do)sum2="+sum2);
    }

}
